<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>塞纳皇宫-网站后台管理系统</title>

    <meta name="keywords" content="">

    <meta name="description" content="">

    <link rel="icon" href="/static/admin/img/logo.png" type="image/x-icon">

    <link rel="shortcut icon" href="favicon.ico"> <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">

    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">



    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">

    <link href="/static/admin/css/plugins/datapicker/datepicker3.css" rel="stylesheet">

    <link href="/static/admin/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">



    <link href="/static/admin/css/plugins/summernote/summernote.css" rel="stylesheet">

    <link href="/static/admin/css/upload.css" rel="stylesheet">



    <script src="/static/admin/js/city/jquery-1.11.3.min.js"></script>



    <script src="/static/admin/editor/ueditor.config.js"></script>

    <script src="/static/admin/editor/ueditor.all.js"></script>

    <style>



        .uploadbtn,.uploadbtn2{position: absolute;padding: 5px 10px;background: #23b7e5;border-radius: 5px;color: #ffffff;z-index: 4}

        .uploadbtn,.uploadbtn2:hover{background: #19a9d5;cursor: pointer;}

        .form-control{cursor: pointer;}

    </style>





</head>



<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">

        <div class="col-sm-12">





            <div class="tabs-left">

                <ul class="nav nav-tabs">

                    <li class="active"><a data-toggle="tab" href="#tab-8" id="add-works">添加/编辑客照</a>

                    </li>

                   <!-- <li class=""><a data-toggle="tab" id="duotu-upload"  href="#tab-9">多图上传</a>

                    </li>-->

                </ul>

            </div>



        </div>



    </div>



    <div class="ibox-content" id="tab-8">

        <form class="form-horizontal m-t" id="works-form" action="" method="post" onsubmit="return subForm()"  enctype="multipart/form-data" >

            <input name="id" id="id" value="{if isset($data)}{$data.id}{/if}" type="hidden">

            <div class="form-group">

                <label class="col-sm-1 control-label">标题：</label>

                <div class="col-sm-2">

                    <input id="title" name="title"  class="form-control" type="text" required=""  value="{if isset($data)}{$data.title}{/if}">


                </div>

            </div>
            
             <div class="form-group">

                <label class="col-sm-1 control-label">外币链接：</label>

                <div class="col-sm-2">

                    <input id="title" name="url"  class="form-control" type="text" required=""  value="{if isset($data)}{$data.url}{/if}">


                </div>

            </div>













<!--            <div class="form-group">

                <label class="col-sm-1 control-label">显示状态：</label>

                <div style="margin-left: 20px;" class="radio radio-info radio-inline">

                    <input type="radio" id="inlineRadio1" value="1" name="is_show" checked="" {if isset($data) && $data.is_show ==1 }checked{/if}>

                    <label for="inlineRadio1"> 显示</label>

                </div>

                <div style="margin-left: 32px;" class="radio radio-inline radio-danger">

                    <input type="radio" id="inlineRadio2" value="0" name="is_show" {if isset($data) && $data.is_show ==0 }checked{/if}>

                    <label for="inlineRadio2"> 不显示</label>

                </div>

            </div>-->




            </div>

            <!--<div class="form-group">

                <label class="col-sm-1 control-label">多图上传：</label>



                <div class="col-sm-3" id="T_upload">



                </div>

            </div>-->

 

            <div class="form-group" style="display: none" id="Works_Upload">



            </div>



            <div class="form-group">

                <div class="col-sm-8 col-sm-offset-3">

                    <button class="btn btn-primary" type="submit" >提交</button>

                </div>

            </div>



        </form>

    </div>







</div>







<script src="/static/admin/js/jquery.min.js"></script>



<script src="/static/admin/js/jquery-1.7.2.min.js"></script>

<script src="/static/admin/layer/layer.js"></script>





<!-- 自定义js -->



<script src="/static/admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>

<!--<script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>-->

<script src="/static/admin/laydate/laydate.js"></script>

<!--script src="/static/admin/layer/layer.css"></script>-->







<script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>

<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>

<script src="/static/admin/js/plugins/summernote/summernote.js"></script>

<script src="/static/admin/js/plugins/summernote/summernote-zh-CN.js"></script>



<script src="http://www.jq22.com/jquery/jquery-1.7.1.js"></script>

<script src="/static/admin/js/T_upload.js"></script>



<script  type="text/javascript">

    $(function(){

        $('.uploadbtn').click(function(){

            return $('#main_img').click();

        })

    })

    $(function(){

        $('.uploadbtn2').click(function(){

            return $('#vice_img').click();

        })

    })

    changeDate();

    function changeDate(){

        var is_date = $("input[name='column_id']:checked").data('id');

        var is_week = $("input[name='column_id']:checked").data('id2');



        if(is_date ==1 && is_week==0){

            $("#date").css('display','block');

            $("#div-month").css('display','none');

            $("#week").css('display','none');

            $("#month").val('');

            $('#select-week').find('option').eq(0).attr("selected","selected");

        }

        if(is_date == 0 && is_week==1){

            $("#date").css('display','none');

            $("#div-month").css('display','block');

            $("#week").css('display','block');

            $("#create_time").val('');



        }



    }

    function subForm(){

        var formobj = document.getElementById('works-form')

        var formData = new FormData(formobj);

        var is_date = $("#inlineRadio3:checked").data('id');



        var is_week  = $("#inlineRadio4:checked").data('id2');



        var month = $("#month").val();

        var week = $("#select-week").val();

        var create_time = $("#create_time").val();


 


        $.ajax({
            url:"/admin.php/cs/addcg",
            data:formData,
            type:"post",
            dataType:'json',
            processData: false,  // 告诉jQuery不要去处理发送的数据
            contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
            success:function(res){
                if(1==res.code) {
                    layer.msg(res.msg);
                    setTimeout(function(){
                       //window.location.href="/admin.php/Psjd/cg";
                        window.history.go(-1);
                    },1000)
                }else{
                    layer.msg(res.msg);
                    return false;
                }
            },

            error:function(){

                layer.msg('系统错误');

                return false;

            },



        });

        return false;

    }


    $(".onDelPic").live('click',function(){

        var id = $(this).attr('idstr');

        var works_pic = '';

        $("#Works_Upload .works_pic").each(function(){

            works_pic = $(this).val();

            if(works_pic == id){

                $(this).remove();

            }

        })

        $.ajax({

            url:"/admin.php/Style/delworksajax",

            type:"post",//get

            data:{id:id},

            dataType:"json",

            success:function(data){

            },

        });

        var id_=$(this).attr("data");

        $.Tupload.onDelete(id_,id);

        $("#lhezi"+id_).removeClass('show');

    });



    function uploadImg(file, showImg) {

        if (!file.files[0]) {

            return false;

        }

        if (!file.value.match(/.jpg|.gif|.png|.jpeg/i)) {

            layer.msg('您选择的图片格式不正确，请重新选择');

            return false;

        }

        if (file.files[0].size > 1 * 1024 * 1024) {

            layer.msg('您选择的图片不能大于1M，请重新选择！');

            return false;

        }

        var myPhoto = document.getElementById(showImg);

        var reader = new FileReader();

        reader.onload = function (e) {

            var dataURL = e.target.result;

            myPhoto.src = dataURL;

            myPhoto.style.display = 'block';

        };

        reader.readAsDataURL(file.files[0]);

    }

</script>





</body>





</html>

